home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS11.ADF
/
AmigaBasicProgs
/
Hilbert.MSB
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1986-08-05
|
1KB
|
56 lines
REM *****************************************
REM * HILBERT BY MICHAEL ACKERMAN - 8/27/85 *
REM * AMIGA HACK BY DAVE WELCH - 6/02/86 *
REM * FROM THE JUNE, 1986 BYTE MAGAZINE *
REM *****************************************
DEFINT A-Z
GOTO MAIN
HILL: rder = rder - 1
TURN = - TURN
TEMP = DY:DY = - TURN * DX:DX = TURN * TEMP
IF rder > 0 THEN GOSUB HILL
X = X + DX:Y = Y + DY:CALL HPLOT (X, Y)
TURN = - TURN
TEMP = DY:DY = -TURN * DX:DX = TURN * TEMP
IF rder > 0 THEN GOSUB HILL
X = X + DX:Y = Y + DY:CALL HPLOT (X, Y)
IF rder > 0 THEN GOSUB HILL
TEMP = DY:DY = -TURN * DX:DX = TURN * TEMP
TURN = - TURN
X = X + DX:Y = Y + DY:CALL HPLOT (X, Y)
IF rder > 0 THEN GOSUB HILL
TEMP = DY:DY = - TURN * DX:DX = TURN * TEMP
TURN = - TURN
rder = rder + 1
RETURN
MAIN: WINDOW OUTPUT 1:WINDOW CLOSE 2:SCREEN CLOSE 2:CLS
INPUT "ORDER <1-7> ";rder
IF rder = 0 THEN END
IF rder > 5 THEN
SCREEN 2, 640, 400, 1, 4
WINDOW 2, "Hilbert Curve", (1,1)-(631,386), 0, 2
WINDOW OUTPUT 2
POWER = 2^rder
DY = 300 / POWER
ELSE
SCREEN 2, 320, 200, 1, 1
WINDOW 2, "Hilbert Curve", (1,1)-(311,186), 0, 2
WINDOW OUTPUT 2
POWER = 2^rder
DY = 150 / POWER
END IF
TURN = -1
DX = 0:X = 0:Y = 0
OLDX = 0:OLDY = 0
GOSUB HILL
LINE INPUT A$
GOTO MAIN
SUB HPLOT (XX, YY) STATIC
SHARED OLDX, OLDY
LINE (OLDX, OLDY) - (XX, YY)
OLDX = XX:OLDY = YY
END SUB